<template>
  <div class="top-wrap">
      <van-nav-bar :title="title" :left-text="showBack? '返回': ''" :left-arrow="showBack ? true: false" @click-left="goBack" @click-right="goSearch">
        <template #right>
          <van-icon name="search" size="18" v-show="showSearch" />
        </template>
      </van-nav-bar>
  </div>
</template>

<script>
export default {
  props:{
    title: {
      type: String,
      default: ''
    },
    showBack: Boolean,
    showSearch: Boolean
  },
  name: 'top',
  mounted() {
    // console.log(this.showSearch)
  },
  methods: {
    goBack () {
      this.$router.back(-1)
    },
    goSearch () {
      this.$router.push({
        path: '/search'
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">

</style>
